package com.m3958.firstgwt.client.datasource;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import com.m3958.firstgwt.client.constants.TableSchemaFieldConstants;
import com.m3958.firstgwt.client.types.TableSchemaField;
import com.m3958.firstgwt.shared.type.CommonField;
import com.smartgwt.client.data.fields.DataSourceBooleanField;
import com.smartgwt.client.data.fields.DataSourceTextField;


@Singleton
public class TableSchemaDataSource extends BaseDataSource{

    
    public static String className = "com.m3958.firstgwt.server.model.TableSchema";
    
    @Inject
    public TableSchemaDataSource(DsErrorHandler deh,TableSchemaFieldConstants constants) {
    	setID("TableSchemaDs");
       
        DataSourceTextField nameField = new DataSourceTextField(CommonField.NAME.getValue(),constants.name());
        DataSourceBooleanField anonymousReadField = new DataSourceBooleanField(TableSchemaField.ANONYMOUS_READ.getValue(),constants.anonymousRead());
        DataSourceBooleanField hasAuditFieldField = new DataSourceBooleanField(TableSchemaField.HAS_AUDIT_FIELD.getValue(),constants.hasAuditField());
        DataSourceBooleanField hasPublicFieldField = new DataSourceBooleanField(TableSchemaField.HAS_PUBLIC_FIELD.getValue(),constants.hasPublicField());
        DataSourceTextField schemaJsonField = new DataSourceTextField(TableSchemaField.SCHEMA_JSON.getValue(),constants.schemaJson());
        schemaJsonField.setHidden(true);

        addHandleErrorHandler(deh);
        setFields(nameField,getIdField(),anonymousReadField,hasAuditFieldField,hasPublicFieldField,getSiteIdField(constants),getPositionField(constants),getCreatedAtField(false,constants),getVersionField(),schemaJsonField);
        setClientOnly(false);
    }
    
	@Override
	protected String getModelClassName() {
		return className;
	}
}
